<!--  -->
<template>
  <div class="">
    <!-- <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="username"
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <van-field
        v-model="password"
        type="password"
        name="password"
        label="密码"
        placeholder="密码"
        :rules="[{ required: true, message: '请填写密码' }]"
      />
      <div style="margin: 16px">
        <van-button round block color="#1baeae" native-type="submit">
          登录
        </van-button>
      </div>
    </van-form> -->
    {{ baseUrl }}
    <!-- <h1>{{ count }}</h1>-->
    <van-button color="#1baeae" @click="onSubmit">测试</van-button>
  </div>
</template>

<script>
import { reactive, toRefs, onMounted, onUpdated, inject } from 'vue'
export default {
  name: '',
  components: {},
  setup() {
    const testState = reactive({
      count: 0,
      increase: () => {
        testState.count++
      }
    })
    const baseUrl = inject('$location')
    const $http = inject('$http')
    onMounted(() => {
    })
    onUpdated(() => {
      console.log('onUpdated')
    })

    const state = reactive({
      username: "13150468656",
      password: "123456",
    })
    const onSubmit = (() => {
      $http.post("/oauth/service/isLogin?name=" + state.username + "&password=" + state.password)
        .then((res) => {
          console.log(res.data)
        })
    })

    //这里存放数据
    return {
      baseUrl,
      ...toRefs(state),
      ...toRefs(testState),
      onSubmit,
    }
  },
}
</script>